﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example10.aspx.cs" Inherits="Chapter30.Example10" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 30-10 事件冒泡</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style title="cor styles">
        p {
            background: gray;
            color: white;
            padding: 10px;
            border: thin solid black;
        }
    </style>
</head>
<body>
    <p>
        <a href="http://apress.com">Visit Apress</a>
        <a href="http://w3c.org">Visit W3C</a>
    </p>
    <script>
        var elems = document.querySelectorAll("a");
        for (var i = 0; i < elems.length; i++) {
            elems[i].addEventListener("click", handleClick, false);
        }

        function handleClick(e) {
            if (!confirm("Do you want to navigate to " + e.target.href + " ?")) {
                e.preventDefault();
            }
        }
    </script>
</body>
</html>
